package com.ebc.eservice.controller.app;

import com.ebc.eservice.service.app.CardManageService;
import com.ebc.eservice.service.app.PersonCardService;
import com.ebc.eservice.util.JsonResult;
import com.ebc.eservice.util.common.constant.ApiTextHelperConstant;
import com.ebc.eservice.util.common.constant.DeveloperConstant;
import com.ebc.eservice.vo.card.updateCardPicVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author: Joey
 * @Description:名片管理
 * @date:2022/9/25 15:06
 */
@Api(tags = "小程序-名片管理-[留言管理][简介管理]")
@RestController
@RequestMapping("/appCardManage")
public class CardManageController {

    @Autowired
    private CardManageService cardManageService;
    @Autowired
    private PersonCardService messageService;

    /**
     *  名片-个人简介管理
     *
     * */
    @ApiOperation(value = "名片管理-修改名片个人简介-图片添加功能", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/updateProfile")
    public JsonResult updateProfile(@RequestParam(value = "file") MultipartFile file,
                                    @RequestParam(value = "cardId") int cardId,
                                    @RequestParam(value = "personProfile") String personProfile) throws IOException {
        updateCardPicVo picVo = new updateCardPicVo();
        picVo.setFile(file).setCardId(cardId).setPersonProfile(personProfile);
        return  cardManageService.updatePersonProfile(picVo);
    }

    /**
     *  留言管理
     *
     * */

    @ApiOperation(value = "根据名片id获取全部留言 [包括状态-公开未公开,回复未回复]", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getAllMsgList")
    public JsonResult getMsgAllList(@RequestParam Integer cardId){
        return  messageService.getAllMsgByCardId(cardId);
    }

    @ApiOperation(value = "获取留言概况数量", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getStatMsg")
    public JsonResult getStatMessage(Integer cardId){
        return  messageService.getStatMessage(cardId);
    }

    @ApiOperation(value = "删除留言-根据留言id", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/deleteMsg")
    public JsonResult deleteMsg(Integer mid){
        return  messageService.deleteMessage(mid);
    }

}
